import { Button, List ,Dialog,Toast} from 'antd-mobile'
import { inject, observer } from 'mobx-react'
import React, { FC } from 'react'
import { useNavigate } from 'react-router-dom'
import Myhead from '../../components/myhead'

const Setting:FC<any>=({
    uinfo
})=> {
    const {userInfo,changeInfo,changeInfoAsync}=uinfo 
    const navigator=useNavigate()
    
    const gotoLogin=()=>{
        Dialog.confirm({
          content: '是否退出登录',
          onConfirm:() => {
            changeInfo(null)
            navigator("/login")
            Toast.show({
              icon: 'success',
              content: '退出成功',
              position: 'bottom',
            })
            Dialog.clear()
            throw new Error()
          },
        })
        
    }
  return (
    <div>
        <Myhead title="设置" back="true"/>
        <List style={{marginTop:"0.44rem"}}>
          <List.Item onClick={() => {navigator('/changepass')}}>
            修改密码
          </List.Item>
        </List>
        <List style={{marginTop:'0.1rem'}}>
          <List.Item  onClick={() => {navigator('/home/news')}}>
              课程 
          </List.Item>
        </List>

        <List style={{marginTop:'0.15rem'}}>
          <List.Item style={{display:"flex",justifyContent:'space-evenly',color:"red"}}
          arrow=''
          onClick={gotoLogin}>
            退出登录
          </List.Item>
        </List>
    </div>
  )
}

export default inject('uinfo')(observer(Setting))